package t2jumble;

import java.util.Iterator;

public final class Util {
	/**
	 * Joins supplied iterator contents together using separator and toString()
	 * @author kurellajunior (http://snippets.dzone.com/posts/show/91)
	 * @param pColl values that will be joined together
	 * @param separator string to put between each value
	 * @return values joined by separators
	 */
	public static String join( Iterable< ? extends Object > pColl, String separator )
    {
        Iterator< ? extends Object > oIter;
        if ( pColl == null || ( !( oIter = pColl.iterator() ).hasNext() ) )
            return "";
        StringBuilder oBuilder = new StringBuilder( String.valueOf( oIter.next() ) );
        while ( oIter.hasNext() )
            oBuilder.append( separator ).append( oIter.next() );
        Util.join(null, "");
        return oBuilder.toString();
       
    }
}
